#include<iostream>
#include<string>
#include<thread>
#include<vector>
#include<functional>

using namespace std;

class Thread{
    public:
        Thread(function<void()> func) : _func(func){};
        thread start()
        {
            thread t(_func);
            return t;
        }
    private:
        function<void()> _func;
};

class ThreadPool
{
    public:
        ThreadPool(){};
        ~ThreadPool(){
            for (int i = 0;i<_pool.size();i++)
            {
                delete _pool[i];
            }
        };
        void startPool(int size)
        {
            for (int i = 0; i < size; i++)
            {
                _pool.push_back(new Thread(bind(&ThreadPool::runThread,this,i)));
            }
            for (int i = 0; i < size; i++)
            {
                _handler.push_back(_pool[i] -> start());
            }
            for (int i = 0; i < size;i++)
            {
                _handler[i].join();
            }
        }
    private:
        vector<Thread*> _pool;
        vector<thread> _handler;
        void runThread(int id)
        {
            cout << "call run Thread id :" << id << endl;
        }
};

int main()
{
        ThreadPool pool;
        pool.startPool(10);
        return 0;
}